<template>
  <basic-container>
    <avue-crud
      :data="tableData"
      :option="tableOption"
      :table-loading="Loading"
      :page.sync="page"
      @on-load="onLoad"
      @refresh-change="onLoad"
      @search-change="searchChange"
    >
      <template slot-scope="scope" slot="menu">
        <el-button type="text" icon="el-icon-view" size="small" @click.stop="errorInfo(scope.row)">查看日志</el-button>
      </template>
    </avue-crud>
    <el-dialog class="avue-dialog avue-crud__dialog" append-to-body
               :title="'查看日志'"
               :visible.sync="logDialog"
               width="60%">
      <div class="content-log">
        <div class="content-log-box" >
          <textarea class="textarea-ft" v-model="logContent" id="textarea-log" style="width: 100%" spellcheck="false" ></textarea>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button icon="el-icon-circle-close" size="small" @click="logDialog = false">取消</el-button>
      </div>
    </el-dialog>
  </basic-container>
</template>
<script>
  import mLog from '../metadata/log';
import { getLogList,viewLog } from '@/api/dataMaintenance/fileStorageLog';
  export default {
    components: { mLog },
    data(){
      return {
        logContent:'',
        Loading:false,
        page: {
          pageSize: 10,
          currentPage: 1,
          total: 0
        },
        logDialog: false,
        item: {},
        source: 'list',
        logId: 285,
        tableData: [],
        tableOption: {
          // height: 'auto',
          // calcHeight: 30,
          tip: false,
          searchShow: true,
          searchMenuSpan: 6,
          border: false,
          editBtn: false,
          addBtn: false,
          delBtn: false,
          // viewBtn: true,
          // delBtn: false,
          // menuWidth: 350,
          dialogClickModal: false,
          menuWidth: 180,
          column: [
            {
              label: '文件名称',
              prop: 'name',
              search: true,
              width: 140
            },
            {
              label: '状态',
              prop: 'status',
              type:'select',
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              dicUrl: '/api/blade-system/dict/dictionary?code=putting_statu',
            },
            {
              label: '开始时间',
              prop: 'createTime',
              type: "date",
              format: "yyyy-MM-dd hh:mm:ss",
              width: 140
            },
            {
              label: '结束时间',
              prop: 'updateTime',
              type: "date",
              format: "yyyy-MM-dd hh:mm:ss",
              width: 140
            },
            {
              label: '操作类型',
              prop: 'operateType'
            },
            {
              label: '操作人',
              prop: 'createUserName'
            }

          ]
        }
      }
    },
    methods: {
      ok () {},
      close () {
        this.logDialog = false
      },
      errorInfo(row) {
        this.logContent = row['logs'];
        this.logDialog = true;

      },
      onLoad(){
        //this.tableData = createList();
        this.getLogList();
      },
      searchChange(params,done) {
        this.page.currentPage = 1;
        this.getLogList(params['name'] || '');
        done();
      },
      getLogList(name = '') {
        this.Loading = true;
        getLogList({
          current: this.page.currentPage,
          size: this.page.pageSize,
          name:name
        }).then( res => {
          console.log(res)
          const data = res.data.data;
          this.page.total = data.total;
          data.records.forEach(item => {
            item['status'] = item['status'] + '';
          });
          this.tableData = data.records;
          this.Loading = false;
        }).catch( error => {
          this.Loading = false;
        });
      },
      viewLog() {
        viewLog().then( res => {

        }).catch( error => {

        });
      },
    }
  }
</script>
<style lang="scss">
  .content-log {
    height: 50vh;
    background: #002A35;
    padding:6px 2px;
  .content-log-box {
    width: 100%;
    height: 100%;
    word-break:break-all;
  textarea {
    background: none;
    color: #9CABAF;
    border: 0;
    font-family: 'Microsoft Yahei,Arial,Hiragino Sans GB,tahoma,SimSun,sans-serif';
    font-weight: bold;
    resize:none;
    line-height: 1.6;
    padding: 0px;
  }
  }
  }
</style>
